//
//  DBManager.h
//  airfight
//
//  Created by aaron on 12-11-24.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#ifndef airfight_DBManager_h
#define airfight_DBManager_h

#include <string>
#include "cocos2d.h"
#include "sqlite3.h"

using namespace std;
USING_NS_CC;


class DBManager : public CCObject
{
private:
    string dbName;
    sqlite3 *pDB;//数据库指针
    char * errMsg = NULL;//错误信息
    string sqlstr;//SQL指令
    int result;//sqlite3_exec返回值

    
public:
    virtual bool init(void);
    bool initWithDBName(const char *dbName);
    void closeDB();
    void insertData(string sql);
    
    void createTable(string sql,string name);
    bool tableIsExist(string tablename);
    static int isExisted( void * para, int n_column, char ** column_value, char ** column_name);
    
    bool initTables();
    bool initDatas();
    
    
    void getPlayerInfo(CCObject *pPlayer);
    static int loadPlayerRecord(void * para, int n_column, char ** column_value, char ** column_name);
    DBManager();
    ~DBManager();
    
    /** returns a single instance of the DBManager */
    static DBManager* getInstance(void);
    
    static DBManager *s_SharedDBManager;
    
};



#endif
